﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SendAnnounce.aspx.cs" Inherits="ZX.WebApp.EditWidows.SysManager.SendAnnounce"
    ValidateRequest="false" %>

<html>
<head id="Head1" runat="server">
    <title></title>
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/JavaScript/jquery.upload.js" type="text/javascript"></script>

	<script type="text/javascript" charset="utf-8" src="../../Scripts/kindeditor-4.1.1/kindeditor.js"></script>
	<script type="text/javascript" charset="utf-8" src="../../Scripts/kindeditor-4.1.1/lang/zh_CN.js"></script>
	<script type="text/javascript" charset="utf-8" src="../../Scripts/kindeditor-4.1.1/plugins/code/prettify.js"></script>

	<script type="text/javascript">
	    //取得HTML        editor.html()
	    //判断是否为空     editor.isEmpty()
	    //取得文本(包含img,embed)   editor.text()
	    //取得选中HTML  editor.selectedHtml()
	    //设置HTML        editor.html('<h3>Hello KindEditor</h3>')
	    //设置文本       editor.text('<h3>Hello KindEditor</h3>')
	    //插入HTML        editor.insertHtml('<strong>插入HTML</strong>');
	    //添加HTML        editor.appendHtml('<strong>添加HTML</strong>');
	    //清空内容      editor.html('');


	    var editor;
	    var getUrl = "http://" + this.location.host + "/EditWidows/";

	    $(document).ready(function () {
	        $('#UpAccessoriesFileName').upload();
	    });

	    KindEditor.ready(function (K) {
	        editor = K.create('#content1', {
	            cssPath: '../../Scripts/kindeditor-4.1.1/plugins/code/prettify.css',
	            uploadJson: '../../Scripts/kindeditor-4.1.1/asp.net/upload_json.ashx?filepath=GongGao&ext={image,flash,media,file}&filesize=1000000',
	            fileManagerJson: '../../Scripts/kindeditor-4.1.1/asp.net/file_manager_json.ashx?filepath=GongGao&ext={image,flash,media,file}&filesize=1000000',
	            allowFileManager: true,
	            afterCreate: function () {
	                var self = this;
	                K.ctrl(document, 13, function () {
	                    self.sync();
	                    K('form[name=form1]')[0].submit();
	                });
	                K.ctrl(self.edit.doc, 13, function () {
	                    self.sync();
	                    K('form[name=form1]')[0].submit();
	                });
	            }
	        });

	        //上传文件
	        K('#insertfile').click(function () {
	            editor.loadPlugin('insertfile', function () {
	                editor.plugin.fileDialog({
	                    fileUrl: K('#url').val(),
	                    clickFn: function (url, title) {
	                        K('#url').val(url);
	                        editor.hideDialog();
	                    }
	                });
	            });
	        });

	        //弹出窗口
	        K('#create1').click(function () {

	            var entityName = "DatDepartment";
	            var url = getUrl + "YUITree.aspx?r=" + Math.random() + "&entity=" + entityName + "&masterPara=DatDepartment|DeptName|DeptID|ParentID|DeptPath|False";

	            var dialog = K.dialog({
	                width: 350,
	                title: '',
	                body: '<div id="deptDIV" style="width:350px;height:450px;"><iframe style="width:100%;height:100%;" src=' + url + '></iframe></div>',
	                closeBtn: {
	                    name: '关闭',
	                    click: function (e) {
	                        dialog.remove();
	                    }
	                },
	                yesBtn: {
	                    name: '确定',
	                    click: function (e) {


	                        var editwindow = document.getElementById("deptDIV");

	                        alert(editwindow);
	                        //                        if (editwindow) {
	                        //                            editwindow.contentWindow.ChooseInfo();
	                        //                            if (_id == "btnCustomerID") {
	                        //                                LoadCustomerData();
	                        //                            }
	                        //                            if (_id == "btnCourseLoyoutID") {
	                        //                                LoadCourseLayout($("#CourseLoyoutID").val());
	                        //                            }



	                    }
	                },
	                noBtn: {
	                    name: '取消',
	                    click: function (e) {
	                        dialog.remove();
	                    }
	                }
	            });
	        });
	    });

	    var Save = function () {
	        var Subject = document.getElementById("txtSubject").value; //标题
	        var Content = editor.html();
	        var DeptID = "";
	        var fileurl = $("#url").val()
	        Content = Coding(Content);
	        var deptId = $("#DeptId").val()
	        $.post("SendAnnounce.aspx?r=" + Math.random(), { "Action": "Save", "Subject": Subject, "Content": Content, "DeptID": DeptID, "url": fileurl }, function (result) {
	            alert(result)
	        }, "json");
	    }


	    //编码
	    function Coding(str) {
	        var re1 = /</g;
	        var re2 = />/g;
	        var re3 = /"/g;
	        var re4 = /&/g;
	        var re5 = /%/g;
	        str = str.replace(re5, "%5");
	        str = str.replace(re4, "%4");
	        str = str.replace(re3, "%3");
	        str = str.replace(re2, "%2");
	        str = str.replace(re1, "%1");
	        return str;
	    }
	</script>

    <style type="text/css">
        .tdRight
        {
            margin:0;
            width:20%;
            text-align:right;
        }
        .tdLeft
        {
            margin:0;
            width:80%;
            text-align:left;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    <div>
        <div id="fieldForm">
            <table bordercolor="#e0ecf8" cellspacing="0" cellpadding="0" align="center" border="1" style="vertical-align: middle;" width="100%">
                <tr>
                    <td valign="middle" align="center" style="margin-top:10px;" colspan="2"><h3> 发布公告通知</h3></td>
                </tr>
                <tr>
                    <td class="tdRight"><label id="lblTitle" for="txtSubject">标题:</label></td>
                    <td class="tdLeft">
                        <textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
                        <input id="txtSubject" style="width: 250px" runat="server" requiretype="1" />
                    </td>
                </tr>
                <tr>
                    <td class="tdRight"><label id="lblDeptS">发布范围:</label></td>
                    <td class="tdLeft">
                        <input type="hidden" id="DeptId" name="DeptId" runat="server" />
                        <input id="txtDeptId" name="txtDeptId" runat="server" readonly="readonly" type="text" style="width: 150px;" />
                        <input type="button" id="create1" value="选择部门" />
                    </td>
                </tr>
                <tr>
                    <td class="tdRight">附件：</td>
                    <td class="tdLeft" colspan="2">
                        <input type="hidden" id="txtName" value=""/>
                       <input type="text" id="url" value="" readonly="readonly" /> 
                       <input type="button" id="insertfile" value="选择文件" />
                    </td>
                </tr>
                <tr>
                    <td class="tdRight">内容：</td>
                    <td class="tdLeft">
                        <textarea id="content1" cols="100" rows="8" style="width:700px;height:200px;visibility:hidden;" runat="server"></textarea>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <img src="../../Images/Peixun/save.bmp" title="保存" style="float: right;cursor: pointer" alt="保存" onclick="return Save();" />
                        <br />
                        <img src="../../Images/Peixun/cancel.bmp" title="重填" style="padding-left: 10px; cursor: pointer" alt="重填" onclick="return ClearValue();" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>
